﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace frmViewItemCatalog
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {

            Session["username"] = txtUserName.Text.ToString();
            
            LogicUniversityT2Entities ct = new LogicUniversityT2Entities();
          
          //  var a = from user in ct.InventoryUsers where user.EmployeeID == txtUserName.Text.ToString() select user;

           //Label.text=

          
               InventoryUser i = ct.InventoryUsers.First<InventoryUser>(cust => cust.EmployeeID == txtUserName.Text);

                if (i != null)
                {

                    if (i.Password.ToString() == txtPassword.Text.ToString())
                    {


                        if (i.Role.ToString() == "M")

                            Response.Redirect("frmManageRequest.aspx");

                        if (i.Role.ToString() == "S")
                            Response.Redirect("RequisitionForm.aspx");


                    }
                    else Label2.Text = "Wrong Password";



                }
            } 

                
           
        }
    }
